Skip to content

[DO NOT MERGE] Fairer Queue implementation for individual queues#4692

Open
DilwoarH wants to merge 8 commits intofeat/fair-queue-skeletonfrom
feat/fair-queue-skeleton--queue-implementation
Open

[DO NOT MERGE] Fairer Queue implementation for individual queues#4692
DilwoarH wants to merge 8 commits intofeat/fair-queue-skeletonfrom
feat/fair-queue-skeleton--queue-implementation

Conversation

@DilwoarH
Copy link
Contributor

What

Implements fairer queue message grouping for individual queues

Queues implemented

  • ✅ SEND_SMS
  • ✅ SEND_LETTER
  • ✅ SEND_EMAIL
  • ✅ JOBS
  • ✅ NOTIFY
  • ✅ CREATE_LETTERS_PDF
  • ✅ CALLBACKS
  • ✅ LETTERS
  • ✅ REPORT_REQUESTS_NOTIFICATIONS (already done in original PR)
  • ❌ DATABASE: Not done as there is no clear way to get a service ID

Why

This is needed to complete the fairer queue work done in #4676

deliver_letter.apply_async(kwargs={"notification_id": id}, queue=QueueNames.SEND_LETTER)
message_group_kwargs = {}
if (current_app.config.get("ENABLE_SQS_FAIR_GROUPING", False)):
notification = get_notification_by_id(id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This celery task was explicitly written so it didn't have to hit the database and this perfectly illustrates my objection to implementing group ids in this way, as mentioned here #4676 (comment) and in many other places.

Copy link
Member

@risicle risicle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not do this

@DilwoarH
Copy link
Contributor Author

Please do not do this

ref: #4676 (comment)


message_group_kwargs = {}
if (current_app.config.get("ENABLE_SQS_FAIR_GROUPING", False)):
notification = notifications_dao.get_notification_by_id(notification_id)
Copy link
Contributor Author

@DilwoarH DilwoarH Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to do this (calling the database) - this is put in as an example

message_group_kwargs = {}

if (current_app.config.get("ENABLE_SQS_FAIR_GROUPING", False)):
notification = Notification.query.filter(Notification.id == notification_id).one()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to do this (calling the database) - this is put in as an example

queue_name = QueueNames.LETTERS
message_group_kwargs = {}
if (current_app.config.get("ENABLE_SQS_FAIR_GROUPING", False)):
notification = Notification.query.filter(Notification.id == notification_id).one()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to do this (calling the database) - this is put in as an example

@DilwoarH DilwoarH changed the title Fairer Queue implementation for individual queues [DO NOT MERGE] Fairer Queue implementation for individual queues Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants